/**
 *	流程模块接口文件：notice通知公告
 *	开发者：雨中磐石
 *	地址：www.rockoa.com
 *	日期：2023-07-19
 */

package com.framework.Module.base.notice;




import com.framerock.baselib.Json;
import com.framerock.baselib.Rock;
import com.framework.Flow.FlowListener;

import java.util.ArrayList;
import java.util.Map;


public class FlowListenernotice extends FlowListener {


    @Override
    public Boolean onModejs() { return true;}

    @Override
    public void onFlowunitadd() {
        mFlow.addOption("行政选项-通知公告类型", "noticetype", new String[]{
                "name=通知",
                "name=规则制度",
                "name=奖惩",
        });

        mFlow.updateUnit(Rock.getMap("issx=1,color=#1CBC7F"), mFlow.funitid, "");
    }

    @Override
    public String ongetFlowwhere(String num) {
        String where = "";
        if(num.equals("my") || num.equals("mytodo")){
            where = "(`startdt` IS NULL OR `startdt`< now()) AND (`enddt` IS NULL OR `enddt`> now())";
        }
        return where;
    }

    @Override
    public String onDefaultOrder() {
        return "`sort` ASC, `optdt` DESC";
    }

    @Override
    public Map<String, String> onReplacers(Map<String, String> da, int lx) {
        if(lx==2)da.remove("content");
        return da;
    }

    @Override
    public Boolean onisPinlun() {
        return true;
    }

    @Override
    public Map<String, String> onhomeData(String pnum) {
        if(Rock.isEmpt(pnum)) {
            Map<String, String> da = Rock.getMap();
            ArrayList<Map<String, String>> data = mFlow.getListData("my","id,title,typename,indate", 5, false);
            da.put("data", Json.getListString(data));
            return da;
        }else{
           return null;
        }
    }
}
